package Loganseabolt.weapons;

import Loganseabolt.util;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.event.brewing.PotionBrewedEvent;

public class Grass_Sword extends ItemSword {

	public Grass_Sword(int par1, EnumToolMaterial par2EnumToolMaterial) 
	{
		super(par1, par2EnumToolMaterial);
		// TODO Auto-generated constructor stub
	}
	   public void registerIcons(IconRegister iconReg)
	    {
	        itemIcon = iconReg.registerIcon("LoganSeaboltModBase:Grass_Sword");
	    }
	   
	   public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
	    {
	        par1ItemStack.damageItem(1, par3EntityLiving);
	        /*
	        this.potionID = par1;
	        this.duration = par2;
	        this.amplifier = par3;
	        this.isAmbient = par4;
	        */
	        //if ((EntitySkeleton)par2EntityLiving  != null)
	        //{
	        //	par2EntityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 5000, 1, false));
	        //}
	        // if ((EntityZombie)par2EntityLiving != null)
	        //{
	        	//par2EntityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 5000, 1, false));
	        //}
	        par2EntityLiving.addPotionEffect(new PotionEffect(Potion.confusion.id, 10, 1, false));
	        par2EntityLiving.addPotionEffect(new PotionEffect(Potion.poison.id, 10, 1, false));
	        par2EntityLiving.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 10, 1, false));
	        
	        return true;
	    }
	   /**
	     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
	     */
	    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
	    {
	        /*
	        if (!par3EntityPlayer.capabilities.isCreativeMode)
	        {
	            --par1ItemStack.stackSize;
	        }
	        */
	        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

	        if (!par2World.isRemote)
	        {
	                //par3EntityPlayer.entityDropItem(par1ItemStack, par2)
	                
	                EntityPig skeley = (EntityPig)new EntityPig(par2World);
	                EntityCow cow = (EntityCow)new EntityCow(par2World);
	                EntityChicken Chicky = (EntityChicken)new EntityChicken(par2World);
	                /*
	                skeley.setPosition(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ);
	                skeley.rotationYaw = par3EntityPlayer.rotationYaw - 90;
	                skeley.posX -= ((double)(MathHelper.cos(skeley.rotationYaw / 180.0F * (float)Math.PI) * 0.16F)) * 100;
	            skeley.posZ -= ((double)(MathHelper.sin(skeley.rotationYaw / 180.0F * (float)Math.PI) * 0.16F)) * 100;
	            */
	                
	                Vec3 skeyPos = util.placeInFrontOfEntity(par3EntityPlayer, 10);
	                Vec3 cowPos = util.placeInFrontOfEntity(par3EntityPlayer, 11);
	                Vec3 chickPos = util.placeInFrontOfEntity(par3EntityPlayer, 12);
	                skeley.setPosition(skeyPos.xCoord, skeyPos.yCoord, skeyPos.zCoord);
	                cow.setPosition(cowPos.xCoord, cowPos.yCoord, cowPos.zCoord);
	                Chicky.setPosition(chickPos.xCoord, chickPos.yCoord, chickPos.zCoord);
	            par2World.spawnEntityInWorld(skeley);
	            par2World.spawnEntityInWorld(cow);
	            par2World.spawnEntityInWorld(Chicky);
	        }
	        par1ItemStack.damageItem(2, par3EntityPlayer);
	        

	        return par1ItemStack;
	    } 
	    	public int getDamageVsEntity(Entity par1Entity)
	    	{
	    		return 1;
	    	}
}
